package per.kongtouxu.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import per.kongtouxu.domain.pojo.PageBean;
import per.kongtouxu.domain.vo.V_AdminLog;
import per.kongtouxu.service.AdminLogService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/adminLog")
public class AdminLogController {
    @Autowired
    private AdminLogService adminLogService;
    @RequestMapping("/findAdminLogByPage")
    public @ResponseBody PageBean<V_AdminLog> findAdminLogByPage(HttpServletRequest req, HttpServletResponse resp){
        //1.获取参数
        String startTime = req.getParameter("startTime");
        String endTime = req.getParameter("endTime");
        String currentPage = req.getParameter("currentPage");
        String pageSize = req.getParameter("pageSize");
        System.out.println(startTime);
        //2.调用service
        PageBean<V_AdminLog> pageBean = adminLogService.findAdminLogByPage(startTime, endTime, currentPage, pageSize);
        //3.返回JSON
        return pageBean;
    }
    //删除日志
    @RequestMapping("/deleteLog")
    public @ResponseBody Integer deleteLog(HttpServletRequest req, HttpServletResponse resp)throws Exception{
        //1.获取参数
        String[] arr = req.getParameterValues("logIdList[]");
        //2,调用service
        int result = adminLogService.deleteSome(arr);
        return result;
    }
}
